package com.xunk.common.core.enums.dnake;


import com.xunk.common.core.interfaces.EnumValidateInterface;

/**
 * @Author: wangTong
 * @Description: 狄耐克控制命令枚举
 * @Date: 2021/5/12 10:50
 * @Version: 1.0
 */
public enum DnakeActionEnum implements EnumValidateInterface {

    PERMITJOIN("permitJoin", "允许入网"),
    SETBIND("setBind", "设备绑定指令"),
    SETUNBIND("setUnBind", "设备解除绑定指令"),
    SETSCENE("setScene", "添加和编辑场景，实现场景联动配置"),
    DELSCENE("delScene", "删除场景，包括场景联动信息"),
    DELALLSCENE("delAllScene", "删除全部场景"),
    SETTIMERSCENE("setTimerScene", "添加定时器场景"),
    DELTIMERSCENE("delTimerScene", "删除定时器场景"),
    SETARMLINKAGE("setArmLinkage", "添加安防联动"),
    DELARMLINKAGE("delArmLinkage", "删除安防联动"),
    DELDEV("delDev", "删除单个设备"),
    DELDEVLIST("delDevList", "批量删除设备"),
    SETLOCKUSER("setLockUser", "锁用户配置"),
    CTRLDEV("ctrlDev", "设备控制"),
    CTRLSCENE("ctrlScene", "场景控制"),
    READDEV("readDev", "读取设备状态"),
    READALLDEVSTATE("readAllDevState", "读取所有设备状态"),
    READALLDEVSTATUS("readAllDevStatus", "读取所有设备的在线状态"),
    READDEVCNT("readDevCnt", "批量读取设备数量"),
    READALLDEVLIST("readAllDevList", "读取所有设备列表"),
    CTRLDEF("ctrlDef", "防区布撤防控制，单独防区布撤防控制，一键全部防区布撤防控制"),
    READDEF("readDef", "读防区布撤防状态"),
    CMTALARM("cmtAlarm", "报警信息推送，即产生报警时主动将报警信息发送给云服务器"),
    CMTDEVINFO("cmtDevInfo", "添加设备 UDP 主动推送设备信息"),
    DISCOVER("discover", "查找网关"),
    MATCH("match", "网关对码绑定"),
    SETACCOUNTLIST("setAccountList", "下发关联 IOT 帐号列表"),
    GETACCOUNTLIST("getAccountList", "获取关联 IOT 帐号列表"),
    GETVERSION("getVersion", "获取网关版本信息"),
    RESTARTDEV("restartDev", "重启网关"),
    SETPANID("setPanID", "重置网关"),
    SETFACTORY("setFactory", "恢复出厂设置"),
    DOWNFILE("downFile", "更新配置文件"),
    DOWNPKG("downPkg", "网关升级");

    private String code;
    private String desc;

    DnakeActionEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        for(DnakeActionEnum dnakeActionEnum : DnakeActionEnum.values()){
            if(dnakeActionEnum.getCode().equals(code)){
                return dnakeActionEnum.getDesc();
            }
        }
        return null;
    }

    /**
     * 判断是否是可用枚举
     *
     * @param code
     * @return
     */
    @Override
    public Boolean isValidEnum(String code) {
        for (DnakeActionEnum value : DnakeActionEnum.values()) {
            if (value.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
